package vo

import (
	"cgs-server/helper"
	"cgs-server/server/cgs/app/models"
)

type WorksheetRow struct {
	RowId       string         `json:"rowId" bson:"rowId"`
	WorksheetId string         `json:"worksheetId" bson:"worksheetId"`
	Owner       string         `json:"owner" bson:"owner"`
	Data        models.RowData `json:",inline" bson:",inline"`
}

type WorksheetRowList []*WorksheetRow

func (w *WorksheetRow) MarshalJSON() ([]byte, error) {
	result := make(map[string]interface{})
	result["rowId"] = w.RowId
	result["worksheetId"] = w.WorksheetId
	result["owner"] = w.Owner
	if w.Data != nil {
		for k, v := range w.Data {
			result[k] = v
		}
	}
	return helper.ToJSON(result)
}
